package com.shopping_back.controller;


import com.shopping_back.common.Result;
import com.shopping_back.service.IRefundRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 退款记录表 前端控制器
 * </p>
 *
 * @author Jack
 * @since 2025-07-12
 */
@RestController
@RequestMapping("/api/refund-record")
@RequiredArgsConstructor
public class RefundRecordController {

    private final IRefundRecordService refundRecordService;

    @GetMapping("/refunds")
    public Result getRefunds(@RequestParam Integer page, @RequestParam Integer size, @RequestParam Long merchantId) {
        return Result.success(refundRecordService.getRefunds(merchantId, page, size));
    }

    @PostMapping("/refunds/approve")
    public Result approveRefund(@RequestParam Long paymentId, @RequestParam String refundSn, @RequestParam Long merchantId) {
        refundRecordService.approveRefund(paymentId, refundSn, merchantId);
        return Result.success();
    }

    @PostMapping("/refunds/reject")
    public Result rejectRefund(@RequestParam Long paymentId, @RequestParam String refundSn, @RequestParam Long merchantId) {
        refundRecordService.rejectRefund(paymentId, refundSn, merchantId);
        return Result.success();
    }

}
